package org.point.dao.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

import javax.management.RuntimeErrorException;

import org.point.common.dao.impl.BaseDaoImpl;
import org.point.common.util.DoPage;
import org.point.dao.DeliveryInfoDao;
import org.point.domain.ConvertRuleDetail;
import org.point.domain.DeliveryInfo;
import org.springframework.stereotype.Repository;

/**
 * 
 * @ClassName: ConvertRuleDetailDaoImpl  
 * @Description: TODO(兑换规则明细数据实现类)  
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午3:28:17  
 *
 */
@Repository("DeliveryInfoDao")
public class DeliveryInfoDaoImpl extends BaseDaoImpl<DeliveryInfo, Serializable> implements DeliveryInfoDao {

	/**
	 * 利用反射，获取mapper.xml的namespace
	 * <p>Title: </p>  
	 * <p>Description: </p>
	 */
	public DeliveryInfoDaoImpl() {
		namespace = super.getNamespace();
	}
	

	private static final String SQLID_FIND_DELIV_FOR_MEM_PAGE = "find_deliv_For_Mem_Page";
	
	private static final String SQLID_FINDDELIVFORMEMCOUNT = "find_deliv_For_Mem_Count";

	private static final String SQLID_SELECTUSERIDBYDEVID = "search_userid_devId";

	private static final String SQLID_SEARCHDEVINFO = "search_dev_info";
	
	
	public List<DeliveryInfo> findDeyForMem(DoPage<DeliveryInfo> page) {
		// TODO Auto-generated method stub
		List <DeliveryInfo> records = null;
		try {
			records = getSqlSession().selectList(namespace + SQLID_FIND_DELIV_FOR_MEM_PAGE, page);
		} catch (Exception e) {
			// TODO Auto-generated catch blocks
			throw new RuntimeException("查询收货人信息出错",e);
		}
		return records;
	}

	public Integer countDeyForMem(DoPage<DeliveryInfo> page) {
		// TODO Auto-generated method stub
		Integer records =0;
		try {
			records=getSqlSession().selectOne(namespace + SQLID_FINDDELIVFORMEMCOUNT, page);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new RuntimeException("统计收货人信息出错",e);
		}
		return records;
	}

	public String selectUserIdByDev_id(String devId) {
		String userid = null;
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("devId", devId);
		try {
			userid = getSqlSession().selectOne(namespace + SQLID_SELECTUSERIDBYDEVID, map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return userid;
	}

	public Hashtable<Object, Object> getDevInfo(Map<String, Object> map) {
		Hashtable<Object, Object> record = null;
		try {
			record = getSqlSession().selectOne(namespace + SQLID_SEARCHDEVINFO,map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return record;
	}

}
